package com.lzb.newloan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lzb.newloan.R;
import com.lzb.newloan.pojo.BorrowPersonPojo;

import java.util.ArrayList;

public class InvestPayAdapter extends BaseAdapter {

	private ArrayList<BorrowPersonPojo> pojo;
	private LayoutInflater mInflater;

	public InvestPayAdapter(Context context, ArrayList<BorrowPersonPojo> pojo) {
		this.pojo = pojo;
		this.mInflater = LayoutInflater.from(context);
	}

	public ArrayList<BorrowPersonPojo> getArrayList() {
		return pojo;
	}

	public void setArrayList(ArrayList<BorrowPersonPojo> arrayList) {
		this.pojo = arrayList;
	}

	@Override
	public int getCount() {
		if (pojo == null) {
			return 0;
		} else {
			return pojo.size();
		}
	}

	@Override
	public Object getItem(int arg0) {

		return pojo.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int postition, View convertView, ViewGroup arg2) {
		ViewHoler viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHoler();
			convertView = mInflater.inflate(R.layout.adapter_invest_pay_item, null);
			viewHolder.name = (TextView) convertView.findViewById(R.id.name);
			viewHolder.bank_card = (TextView) convertView
					.findViewById(R.id.bank_card);//收款银行
			viewHolder.money = (TextView) convertView.findViewById(R.id.money);//借款金额
			viewHolder.day = (TextView) convertView.findViewById(R.id.day);//期限
			viewHolder.all_money = (TextView) convertView
					.findViewById(R.id.all_money);//收益
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHoler) convertView.getTag();
		}
		BorrowPersonPojo data = pojo.get(postition);

		viewHolder.name.setText("借款人："+data.getUsername());
		viewHolder.day.setText( data.getDay());
		viewHolder.money.setText(data.getFk_money() + "元");
		viewHolder.all_money.setText(data.getJk_money() + "元");
		viewHolder.bank_card.setText(data.getFkTime()+"");
		return convertView;
	}

	public class ViewHoler {
		public TextView name, money, day, all_money,bank_card;
	}

}
